#!/usr/bin/bash
#
# Init T-One and T-One Agent
#

FILE=$(readlink -f "${BASH_SOURCE[0]}")
CDIR=$(dirname "$FILE")
NAME=$(basename "$FILE")
TMPDIR=${TMPDIR:-"/tmp"}

set -x
#
# XXX: Note that 'admin_urls_token' can be found in the docker-compose.yaml
#      e.g.
#      $ grep admin_urls_token ~/tone/docker-compose.yaml
#      admin_urls_token: ff732f73-8658-4dc0-aab4-447e16950a64
#
admin_urls_token=${1?"***token, e.g. ff732f73-8658-4dc0-aab4-447e16950a64"}
curl -s "http://127.0.0.1:8080/admin/migrate/?token=${admin_urls_token}"
curl -s "http://127.0.0.1:8080/admin/init_data/?token=${admin_urls_token}"
curl -s "http://127.0.0.1:8080/admin/create_superuser/?token=${admin_urls_token}&username=admin&password=admin123"
curl -s "http://127.0.0.1:8081/admin/migrate/?token=${admin_urls_token}"
curl -s "http://127.0.0.1:8081/admin/create_superuser/?token=${admin_urls_token}&username=admin&password=admin123"
curl -s "http://127.0.0.1:8081/admin/import_access_token/?token=${admin_urls_token}"
